﻿namespace Arbalest.Models
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Xml.Serialization;
    using System.Runtime.Serialization;
    using System.Data.Objects.DataClasses;
    using Arbalest.Web.Controllers;

    /// <summary>
    /// Company header
    /// </summary>
    public class Company
    {
        public long Id { get; set; }

        [DisplayName("Company Name")]
        [Required(ErrorMessage = "Company name cannot be undefined.")]
        public string Name { get; set; }

        [DisplayName("Date")]
        [DataType(DataType.Date)]
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
        [Required(ErrorMessage = "Date cannot be undefined.")]
        public DateTime? CreatedDateTime { get; set; }

        public ICollection<StorageLocation> StorageLocations
        {
            get
            {
                DataStore ds = new DataStore();
                return ds.GetList<StorageLocation>().Where(location => location.CompanyId == this.Id).ToList();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public ICollection<Item> Items
        {
            get
            {
                DataStore ds = new DataStore();
                return ds.GetList<Item>().Where(item => item.CompanyId == this.Id).ToList();
            }
            set
            {
                throw new NotImplementedException();
            }
        }
    }

    public class ExchangeCompany
    {
        public string Exchange { get; set; }
        public string Symbol { get; set; }
        public string Name { get; set; }
        public decimal LastSale { get; set; }
        public decimal MarketCap { get; set; }
        public string IPOyear { get; set; }
        public string Sector { get; set; }
        public string Industry { get; set; }
        public string QuoteUrl { get; set; }
    }
}
